home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (PO) / Nibble Volume 12, No. 08 (1991-08)(MindCraft Publishing)(Side A)[a].zip / Nibble Volume 12, No. 08 (1991-08)(MindCraft Publishing)(Side A)[a].po / LPLOT.S < prev    next >
Text File  |  1996-12-24  |  3KB  |  81 lines

  1. ********************************
  2. * LPLOT.S Source Code          *
  3. * By David Harris              *
  4. * (C) 1991 by                  *
  5. * MindCraft Publ. Corp.        *
  6. * Lincoln, MA  01773           *
  7. * Merlin Assembler             *
  8. ********************************
  9.  
  10. * This program plots a table of lines using the
  11. * HPLOT_TO and HPOSN calls.  The table must be
  12. * identified by a pointer POKED into addresses
  13. * $06 and $07.  It must be in the following format:
  14. *  BYTE 3N:   MSB of X Coordinate for line
  15. *  BYTE 3N+1: LSB of X Coordinate for line
  16. *  BYTE 3N+2: Y Coordinate for line
  17. * If the MSB of the X coordinate is greater than $7F
  18. * then, instead of drawing a line, LPLOT merely moves
  19. * the high-resolution cursor.  If both the MSB and LSB
  20. * of the X coordinate exceed $7F, the end of the table
  21. * is signaled and the routine terminates.
  22.  
  23.           ORG $300
  24.  
  25. TBL       EQU $06        ; $06-07 = POINTER TO TABLE
  26. XTEMP     EQU $08        ; $08 = TEMP STORAGE
  27. HPOSN     EQU $F411      ; MOVE HIGH-RES CURSOR
  28. HPLOT_TO  EQU $F53A      ; DRAW A LINE TO A POINT
  29.  
  30. LOOP      LDY #$00       ; START OF TABLE
  31.           LDA (TBL),Y    ; GET X MSB
  32.           BMI SKIP       ; IF MSB >= $80 THEN SKIP
  33.           TAX            ; X MSB IN X REGISTER
  34.           INY            ; NEXT BYTE
  35.           LDA (TBL),Y    ; GET X LSB
  36.           STA XTEMP      ; STORE TEMPORARY
  37.           INY            ; NEXT BYTE
  38.           LDA (TBL),Y    ; GET Y COORDINATE
  39.           TAY            ; Y POS IN Y REGISTER
  40.           LDA XTEMP      ; X LSB IN ACCUMULATOR
  41.  
  42. * The following values should be in each register,
  43. * in preparation for the call to HPLOT_TO:
  44. *  X:   X MSB OF COORDINATE
  45. *  ACC: X LSB OF COORDINATE
  46. *  Y:   Y VALUE OF COORDINATE
  47.  
  48.           JSR HPLOT_TO   ; DRAW LINE
  49.           CLC            ; ADVANCE TABLE POINTER
  50. REPEAT    LDA TBL        ; GET LSB OF TABLE
  51.           ADC #$03       ; MOVE TO NEXT ENTRIES
  52.           STA TBL        ; AND STORE
  53.           LDA TBL+1      ; GET MSB OF TABLE
  54.           ADC #$00       ; WRAP AROUND TO NEXT PAGE
  55.           STA TBL+1      ; AND STORE
  56.           CLC
  57.           BCC LOOP       ; REPEAT CYCLE
  58.  
  59. SKIP      SEC
  60.           SBC #$80       ; CLEAR HIGH BIT
  61.           STA XTEMP      ; STORE TEMPORARY
  62.           INY            ; NEXT BYTE
  63.           LDA (TBL),Y    ; GET X LSB
  64.           BMI QUIT       ; IF LSB >= $80 THEN QUIT
  65.           TAX            ; ELSE STORE IN X REGISTER
  66.           INY            ; NEXT BYTE
  67.           LDA (TBL),Y    ; GET Y COORDINATE
  68.           LDY XTEMP      ; RECALL TEMPORARY
  69.  
  70. * The following values should be in each register,
  71. * in preparation for the call to HPOSN:
  72. *  Y:    X MSB OF COORDINATE
  73. *  X:    X LSB OF COORDINATE
  74. *  ACC:  Y VALUE OF COORDINATE
  75. * Note that they differ from the HPLOT_TO registers.
  76.  
  77.           JSR HPOSN      ; MOVE CURSOR
  78.           CLC
  79.           BCC REPEAT     ; REPEAT CYCLE
  80. QUIT      RTS            ; ALL DONE
  81.